import JSEncrypt from 'jsencrypt/bin/jsencrypt'

const publicKey = 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCrmBkomzzgcqKwdFN/0SkZ1yoQxa3yQe9+Wf3+ykhwFo2dUGF2CyilWMR14fcpcm02jFCu67BTE7HUokSfGylYHdufhLGr/oqxLJ3uWxevNECRbQ5w5pTg3Z9LMfdTU6qXWmrxv0V5I8voA/6qMCjxAtlJkHt1QFexcwRgCpH1MwIDAQAB'

const privateKey = 'MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAKuYGSibPOByorB0U3/RKRnXKhDFrfJB735Z/f7KSHAWjZ1QYXYLKKVYxHXh9ylybTaMUK7rsFMTsdSiRJ8bKVgd25+Esav+irEsne5bF680QJFtDnDmlODdn0sx91NTqpdaavG/RXkjy+gD/qowKPEC2UmQe3VAV7FzBGAKkfUzAgMBAAECgYEAi9JCHd5w+osumg4PxAURMqcq9cO+e7rSheiamTUHVZ5rApbu85sgIat1WoEoPzOoXlxzmjUe1nMj4pnexK8DPhxXNcIKHx53KIFzgiEHxl4yvH1R5bX+modDKWQJ23CYHS9zZuTkgEFh51E/lnJAhpclQvavJMeTSLKcz0hGHeECQQDqPvnp7PCc4kgnLGf8CwrabO5j29JqmzQ+hqk2IwGV1XL8YIGK8r6sv4JR/gLrupN+n2rmdaXcGd8tZLaOF4MLAkEAu4ee5ZTf2aB6AfaLySWXirphMn1qwmealnWQEXZ1aj/h6toTlhJ8Tw67uEczaS0KYi5V1scBA4pDL7CCEPIveQJAZ91CrOGdksKW4Z/D/7LZvh4c2fRHaXOmB69n6hQ9iLVbReJ4riaSO0CzRS3PF7zj13pSSRuTTnO+TH9insB4HwJAOdl/egEwANmRabOdsaJoGkKeo02vNmNxe8Kue8SYOfuU/LbjXeM798Nqw1ErmeFsF5eFoWjodigby8Veik27uQJAX7KDfrDkx51W6geXGCEgjU9oGSYWesrs1xACrbUp8uawFKg4fUbo4eJKBhuxKj67ppSbK+vjCOdbNJs2pVqu5Q=='
// 加密
export function encrypt(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPublicKey(publicKey) // 设置公钥
  return encryptor.encrypt(txt) // 对需要加密的数据进行加密
}

// 解密
export function decrypt(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPrivateKey(privateKey)
  return encryptor.decrypt(txt)
}

